package com.aircoinst.orderservice.service.imp;

import com.aircoinst.feign.client.UserClient;
import com.aircoinst.orderservice.mapper.OrderMapper;
import com.aircoinst.orderservice.service.OrderService;
import com.aircoinst.pojo.Order;
import com.aircoinst.pojo.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private UserClient userClient;

    @Override
    public Order getOrderById(Integer id) {
        Order order = orderMapper.getOrderById(id);
        User user = userClient.getUserById(order.getId());
        order.setUser(user);
        return order;
    }
}
